﻿@using KRM.Core
@{
    ViewBag.Title = "View Tasks";
    Layout = "~/Views/Shared/_Layout.cshtml";
    IEnumerable<vViewCurrentTask> currentTasks = ViewBag.CurrentTask;
    IEnumerable<vKRWNewSiteSubmission> siteSubmissions = ViewBag.SiteSubmissions;
    IEnumerable<tblKRWProductFAQ> answers = ViewBag.Answers;
}
<script src="/js/task.js"></script>
<script> 
    initAutoRefreshStatus();
</script>
<div class="container-fluid">
    <div class="box">
        <div class="row-fluid" style="margin-top: 10px">
            <div class="span8">
                <div style="margin-top: 15px">
                    <a class="btn btn-primary" onclick="PopupCenter('/orderview/addtask/0', 600, 608)">New Task!</a>
                    <a class="btn btn-primary" onclick="RefreshCurrentTasks()">Refresh!</a>
                    <a class="btn btn-primary" onclick="ViewNewTasks()">(<span id="CountTaskWaitting">@ViewBag.CountNewTask</span>) New Task Waitting!</a>
                    <a class="btn btn-primary" onclick="PopupCenter('/Task/ViewLogTaskHistory?FilterByDateFrom=1&dateFrom=@DateTime.Now.AddDays(-7).ToString("MM/dd/yyyy")',1200,600)">View Task History!</a>
                </div>
            </div>
            <div class="span4" style="margin-bottom: -55px;">
                <div class="row-fluid" style="text-align: right" id="TaskStatusImg">
                    @Html.Action("TaskRateImage", "task")
                </div>
            </div>
        </div>

        <div class="row-fluid">

            <ul class="tabs tabs-inline tabs-top orderdetail-task-tabs task-tabs">
                <li class="active">
                    <a href="#currenttasks" data-toggle="tab">Current</a>
                </li>
                <li>
                    <a href="#alltasks" data-toggle="tab">All Tasks</a>
                </li>
                <li>
                    <a href="#sitesubmissions" data-toggle="tab">Site Submissions</a>
                </li>
                <li>
                    <a href="#faqadmin" data-toggle="tab">FAQ Admin</a>
                </li>
            </ul>
            <div class="tab-content padding tab-content-inline tab-content-bottom orderdetail-task-tabs-content">
                <div class="tab-pane active" id="currenttasks">
                    @Html.Action("CurrentTask")
                </div>
                <div class="tab-pane" id="alltasks">
                    @Html.Action("ViewAllTasks")
                </div>
                <div class="tab-pane" id="sitesubmissions">
                    <div class="row-fluid">
                        <div class="span9">
                            <fieldset>
                                <legend>Most Recent Question</legend>
                                <div class="row-fluid">
                                    <div class="span2">Supplier filter</div>
                                    <div class="span3">
                                        @Html.DropDownList("CompanyId", null, new { @class = "input-block-level", onchange = "sitesubmissionsfilter(this.value)" })
                                    </div>
                                </div>
                                <div class="most-recent-question">
                                    @foreach (var item in siteSubmissions)
                                    {
                                        <fieldset>
                                            <legend>@item.dateposted</legend>
                                            <div class="row-fluid">
                                                <div class="span5">@item.StoreName
                                                    <textarea class="input-block-level" rows="5" disabled="disabled">@item.Question</textarea>
                                                </div>
                                                <div class="span3">
                                                    Answer
                                                    <textarea class="input-block-level" rows="5" disabled="disabled">@item.answer</textarea>
                                                </div>
                                                <div class="span4">
                                                    <div class="row-fluid">
                                                        <div class="span4">Assigned to</div>
                                                        <div class="span8">
                                                            <input type="text" disabled="disabled" class="input-block-level" 
                                                                   value="@(string.IsNullOrEmpty(item.assignedTo) ? "NOT assigned" : item.assignedTo)"/>
                                                        </div>
                                                    </div>
                                                    <div class="row-fluid">
                                                        <div class="span2"></div>
                                                        <div class="span8">@item.custname</div>
                                                    </div>
                                                    <div class="row-fluid">
                                                        <div class="span4">Tel</div>
                                                        <div class="span8">
                                                            <input type="text" disabled="disabled" class="input-block-level" value="@item.telephone"/>
                                                        </div>
                                                    </div>
                                                    <div class="row-fluid">
                                                        <div class="span2"></div>
                                                        <div class="span8">@item.email</div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row-fluid">
                                                <div class="span8">
                                                    <a href="@item.ProductURL" target="_blank">@item.ProductName</a>
                                                </div>
                                                <div class="span4 text-right">
                                                    <input type="button" class="btn btn-primary" value="Show" onclick="PopupCenter('/task/sitesubmission?questionid=@item.SiteQuestionID    ', 700, 650)"/>
                                                </div>
                                            </div>
                                        </fieldset>
                                    }
                                </div>
                            </fieldset>
                            <fieldset style="height: 200px">
                                <legend>Related Questions</legend>
                            </fieldset>
                        </div>
                        <fieldset class="span3">
                            <legend>Popular Answers</legend>
                            <div class="popular-answers">
                                @foreach (var item in answers)
                                {
                                    <div class="row-fluid">
                                        <textarea class="input-block-level" disabled="disabled" rows="5">@item.Answer</textarea>
                                    </div>
                                }
                            </div>
                            <div class="row-fluid" style="margin-top: 15px; text-align: center">
                                <input type="button" class="btn btn-primary" value="Edit Popular Answers" onclick="PopupCenter('/task/viewpopularanswers', 800, 650)" />
                            </div>
                        </fieldset>
                    </div>
                </div>
                <div class="tab-pane " id="faqadmin">
                    <div class="ajax-loading" style="display: none"></div>
                    <iframe id="ifFaqAdmin" src="" style="border: 0; height: 800px; width: 100%;"></iframe>

                </div>

            </div>
        </div>
    </div>
</div>

